let t = require;
let e = module
let o = e.exports;
o.default = e.exports;

'use strict';
console.log("start");
var _n184,
    i =
        (this && this.__extends) ||
        ((_n184 = function n(t, e) {
            return (_n184 =
                Object.setPrototypeOf ||
                ({
                    __proto__: []
                }
                    instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) {
                        Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                    }
                })(t, e);
        }),
            function (t, e) {
                function o() {
                    this.constructor = t;
                }
                _n184(t, e),
                    (t.prototype =
                        null === e ?
                            Object.create(e) :
                            ((o.prototype = e.prototype), new o()));
            }),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var i,
                r = arguments.length,
                a =
                    r < 3 ?
                        e :
                        null === n ?
                            (n = Object.getOwnPropertyDescriptor(e, o)) :
                            n;
            if (
                'object' ==
                (typeof Reflect === 'undefined' ?
                    'undefined' :
                    typeof (Reflect)) &&
                'function' == typeof Reflect.decorate
            )
                a = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--) {
                    (i = t[s]) &&
                        (a = (r < 3 ? i(a) : r > 3 ? i(e, o, a) : i(e, o)) || a);
                }
            return r > 3 && a && Object.defineProperty(e, o, a), a;
        };
Object.defineProperty(o, '__esModule', {
    value: !0
}),
    (o.WeakGuidePanel = void 0);
var a = t('UIPanel'),
    s = t('UIViewRes'),
    c = t('UILayer'),
    l = t('ComUtils'),
    u = t('AbsGuideAction'),
    h = t('UIMrg'),
    p = t('PlayerMrg'),
    f = cc._decorator,
    d = f.ccclass,
    g =
        (f.property,
            (function (t) {
                function e() {
                    return (null !== t && t.apply(this, arguments)) || this;
                }
                return (
                    i(e, t),
                    (e.prototype.onInit = function () {
                        t.prototype.onInit.call(this),
                            (this._hand = l.default.getNode(this.view, 'hand')),
                            (this._anim = this._hand.getComponent(cc.Animation)),
                            l.default.setSwallowTouches(this.view, !0);
                    }),
                    (e.prototype.onTouchEvenHandler = function (t) {
                        switch (t.type) {
                            case cc.Node.EventType.TOUCH_START:
                                (this._pause = !0),
                                    l.default.setSwallowTouches(this.view, !1);
                                break;

                            case cc.Node.EventType.TOUCH_END:
                            case cc.Node.EventType.TOUCH_CANCEL:
                                this._pause = !1;
                        }
                        this.resetDelayTime();
                    }),
                    (e.prototype.onClose = function () {
                        this._act &&
                            (2 != this._act.guide.id &&
                                p.PlayerMrg.ins.guideComplete(this._act.guide.id),
                                this._act.targetOff(this),
                                (this._act = null));
                    }),
                    (e.prototype.onShow = function () { }),
                    (e.prototype.setData = function (e) {
                        t.prototype.setData.call(this, e),
                            (this._pause = !1),
                            this.resetDelayTime(),
                            this.startGuide(e);
                    }),
                    (e.prototype.resetDelayTime = function () {
                        this._target && this._target.targetOff(this),
                            (this._target = null),
                            (this._hand.active = !1),
                            (this._delay = 2);
                    }),
                    (e.prototype.startGuide = function (t) {
                        var e = cc.js.getClassByName('Guide' + t);
                        (this._act = new e()),
                            this._act.start(t),
                            this._act.on(
                                u.GuideActionEvent.TargetChanged,
                                this.onTargetChangedHandler,
                                this
                            ),
                            this._act.on(
                                u.GuideActionEvent.Complete,
                                this.onCompleteHandler,
                                this
                            ),
                            (this.view.active = !this._act.hide);
                    }),
                    (e.prototype.onTargetChangedHandler = function (t) {
                        null == t && this.resetDelayTime();
                    }),
                    (e.prototype.onCompleteHandler = function () {
                        h.UIMrg.close(this);
                    }),
                    (e.prototype.onUpdate = function (deltaTime) {
                        // 调用父类的onUpdate方法
                        t.prototype.onUpdate.call(this, deltaTime);

                        // 缓存this引用，方便在回调函数中使用
                        var self = this;

                        // 检查是否需要更新引导状态
                        if (!this._pause && this._act && !this._act.isDestroy) {
                            // 更新引导动作
                            this._act.update(deltaTime);

                            // 更新延迟时间
                            this._delay -= deltaTime;

                            // 如果延迟时间已到，执行引导更新
                            if (this._delay <= 0) {
                                // 检查目标节点是否存在且为cc.Node实例
                                if (this._act && this._act.target && this._act.target instanceof cc.Node) {
                                    var targetNode = this._act.target;

                                    // 只有当目标节点改变时才更新引导手位置和动画 
                                    if (this._target != targetNode) {
                                        // 计算引导手的起始位置（转换到当前视图坐标系）
                                        var startPos = this.view.convertToNodeSpaceAR(
                                            targetNode.convertToWorldSpaceAR(cc.Vec2.ZERO)
                                        );

                                        // 计算引导手的目标位置
                                        var endPos;
                                        if (this._act.to) {
                                            // 如果有目标UI元素，转换其位置到当前视图坐标系
                                            endPos = this.view.convertToNodeSpaceAR(
                                                this._act.to.view.convertToWorldSpaceAR(cc.Vec2.ZERO)
                                            );
                                        } else {
                                            // 如果没有目标UI元素，默认在起始位置上方200像素
                                            endPos = cc.v2(startPos.x, startPos.y + 200);
                                        }

                                        // 停止引导手的所有当前动作并设置起始位置
                                        this._hand.stopAllActions();
                                        this._hand.setPosition(startPos);

                                        // 根据引导类型执行不同的动画逻辑
                                        switch (this._act.guide.kind) {
                                            case 0:
                                            case 2:
                                                // 类型0和2：显示引导手并执行淡入动画
                                                this._anim.play('GuideHand');
                                                this._hand.opacity = 0;
                                                cc.tween(this._hand)
                                                    .to(0.5, { opacity: 300 })
                                                    .start();
                                                break;

                                            case 4:
                                                // 类型4：执行引导手势动画（移动到目标位置并点击）
                                                // 计算动画持续时间（基于距离）
                                                var moveDuration = cc.Vec2.distance(startPos, endPos) / 300;

                                                // 存储起始位置，用于循环动画
                                                this._anim.play('GuideHandStop');
                                                this._hand.opacity = 0;
                                                this._hand.pt = startPos;

                                                // 执行移动、点击、返回的循环动画
                                                cc.tween(this._hand)
                                                    .to(moveDuration, { x: endPos.x, y: endPos.y, opacity: 500 })
                                                    .call(function () { self._anim.play('GuideHandClick'); })
                                                    .delay(0.8)
                                                    .call(function (hand) {
                                                        hand.setPosition(hand.pt);
                                                        self._anim.play('GuideHandStop');
                                                    })
                                                    .union()
                                                    .repeatForever()
                                                    .start();
                                                break;
                                        }

                                        // 清理旧目标的事件监听并更新目标引用
                                        if (this._target) {
                                            this._target.targetOff(this);
                                        }
                                        this._target = targetNode;
                                    }

                                    // 确保引导手可见
                                    if (!this._hand.active) {
                                        this._hand.active = true;
                                    }
                                } else {
                                    // 如果没有有效的目标节点，隐藏引导手
                                    if (this._hand.active) {
                                        this._hand.active = false;
                                    }
                                }
                            }
                        }
                    }),
                    (e.RES = new s.UIViewRes(
                        'WeakGuideView',
                        'Guide',
                        c.UILayer.WeakGuideLayer
                    )),
                    r([d('WeakGuidePanel')], e)
                );
            })(a.default));
(o.WeakGuidePanel = g), console.log("end");
module.exports = e.exports;